﻿@using Microsoft.AspNetCore.Http
@{
    ViewData["Title"] = "Index";
    var messages = ViewBag._messagesRepository  as List<Messages>;
    var user =ViewBag .User;
}
<div class="pntLeft">
    <h2 class="Title">用户中心
    </h2>
       </div><!--pntLeft/-->
<div class="pntRight">
    <ul class="nav">
     <li><a href="/home/index">商城首页</a></li>
     <li><a href="/product/index">商品中心</a></li>
     
      <li><a href="/news/index">新闻中心</a></li>
           <li> @if(@Context.Session.GetString(key:"user")==null){
							 <a href="/login/index">用户中心</a>
						}else{
							
							 <a href="/user/index">用户中心</a>
							
						}    </li> 
     <li><a href="/about/index">关于我们</a></li>
     <div class="phone">TEL：021-12345678</div>
 
    </ul><!--nav/-->
   </div><!--pntRight/-->
            <div class="clears"></div>
        </div><!--pnt/-->
        <div class="positions">
            当前位置：<a href="/home/index">首页</a> &gt; <a href="vip.html">会员中心</a>
            &gt; <a href="#" class="posCur">在线留言</a>
        </div><!--positions/-->
        <div class="cont">
            <div class="contLeft" id="contLeft">
                <h3 class="leftTitle">用户中心</h3>
               <dl class="helpNav vipNav">
     <dt>我的主页</dt>
      <dd>
       <a href="/user/index" class="vipCur">个人中心</a>
       <a href="/order/index">我的订单</a>
       <a href="/shoppingcart/index">我的购物车</a>
      </dd>
     
      <dt>客户服务</dt>
      <dd>
      <a href="/message/index">在线留言</a>
      </dd>
    </dl><!--helpNav/-->
            </div><!--contLeft/-->
            <div class="contRight">
                <h2 class="oredrName">
                    在线留言
                </h2>
               <form class="layui-form">
                    <!-- 使用Ajax需要把它删除action="/admin/news/add" method="post"-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-block">
                            <input type="text" value="@user.UserName" name="name1" required lay-verify="required"  autocomplete="off" class="layui-input" style="width:450px">
                        </div>
                    </div>
                      <div class="layui-form-item">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="Phone" required lay-verify="required"  autocomplete="off" class="layui-input" style="width:450px">
                        </div>
                    </div>
                      <div class="layui-form-item">
                        <label class="layui-form-label">留言内容</label>
                        <div class="layui-input-block">                           
                            <textarea name="Ask"  class="layui-textarea" style="height:150px;width:300px"></textarea>
                        </div>
                    </div>
                     <div class="layui-form-item">
                        <div class="layui-input-block">
                           <button class="layui-btn" lay-submit lay-filter="addForm">提交</button><!--使用Ajax把formDemo改为addForm-->
                        </div>
                    </div>
                </form><!--message/-->
            </div><!--contRight/-->
            <div class="clears"></div>
        </div><!--cont/-->
     <div class="inHLeft">
                </ul><!--inHeList/-->
<script src="~/layui/layui.js"></script>
  <script>       
 layui.use(["form", 'layer'], function () {
            var form = layui.form;
            var $ = layui.$;//引入layui组件
            //监听提交
            form.on('submit(addForm)', function (data) {
                $.post("/message/index", data.field, function (res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function () {
                            window.location.href = "/home/index"//parent加上它是父页面做跳转
                        });
                    } else {
                        layer.msg(res.msg)
                    }
                });
                return false;
            });
        });
        </script> 